package cn.yunhe.webSocket;


import cn.yunhe.entity.Emp;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;

public class WebSocketConfig extends Configurator {

    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
     //  System.out.println("进入config+++++++++++++++++");

        HttpSession httpSession = (HttpSession) request.getHttpSession();
        Emp emp= (Emp) httpSession.getAttribute("emp");
        // 将http session信息注入websocket session
        sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
    }

}
